package com.zeus.base.smscenter.restful.api;

import com.google.common.collect.Maps;
import com.zeus.base.smscenter.common.util.HttpClientUtils;

import java.util.Map;

/**
 * Created by Administrator on 2016-03-03.
 */
public class Test1 {

    public static void main(String[] args) throws Exception {


        Map<String,String> params= Maps.newHashMap();
//        String tenant="lzsihaixingcheng";
//        String commpany="四海星辰";
//        String password="lzsihaixingchengfy56";
//        String md5=MD5.generate(password,false).toUpperCase();
//        params.put("data", "{\"smsSupplier\":{\"appPlatform\":\"BS\",\"isUsed\":\"Y\",\"propertyLst\":[{\"isUsed\":\"Y\",\"propertyName\":\"loginName\",\"propertyValue\":\""+tenant+"\",\"supplierType\":\"1\"}," +
//                "{\"isUsed\":\"Y\",\"propertyName\":\"loginPassword\",\"propertyValue\":\""+md5+"\",\"supplierType\":\"1\"}," +
//                "{\"isUsed\":\"Y\",\"propertyName\":\"timeExpire\",\"propertyValue\":\"600\",\"supplierType\":\"1\"}],\"supplierChannel\":1,\"supplierFullName\":\"即时通短信\",\"supplierName\":\"即时通\",\"supplierNo\":\"1\",\"viewSort\":4},\"tenant\":{\"code\":\""+tenant+"\",\"name\":\""+commpany+"\",\"remark\":\"remark\",\"useStatus\":\"Y\"}}");
//       String result= HttpClientUtils.post("http://120.27.197.38:50001/tenant/save", params, null, 10000, 10000);
//
//
//
//        JSONObject josn=JSON.parseObject(result);
//        System.out.println(josn.get("code"));
        
        
//        params.put("data","{\"content\":\"测试内2容dafd\",\"phone\":\"15504607909\",\"tenant\":\"hlwlyxgs\",\"supplierChannel\":\"3\",\"bizType\":\"总共\",\"sendType\":\"WELINK\",\"bizNo\":\"1q2w3e4r\",\"appPlatform\":\"仓配\"}");
        
        
        /******************************
         * 微网通联通道
         ******************************/
        //查询发送纪录
//        params.put("tenant", "fytest123");
//        params.put("begin", "20170328000000");
//        params.put("end", "20170328151515");
//        params.put("data", "{\"page\":\"1\",\"size\":\"20\",\"mobilePhone\":\"15504607909\"}");
//        //发送手机号mobilePhone   
//        //发送内容msgcontent
//        //每页多少条pageSize
//        //当前页curPage
//        //开始时间startTime   格式为yyyyMMddHHmmss
//        //结束时间endTime
//        String result= HttpClientUtils.post("http://120.27.197.38:50008/message/find", params, null, 10000, 10000);

        
        //查询余额
//        params.put("tenant", "xztiandiwl");
//        params.put("data", "{}");  //\"appPlatform\":\"仓配\"
//        String result= HttpClientUtils.post("http://120.27.197.38:50008/smsqueryV2/queryBalanceV2", params, null, 20000, 20000);
        
        //根据总公司查询租户
//        params.put("tenant", "huazhongkuaiyun");
//        params.put("data", "{}");  //\"appPlatform\":\"仓配\"
//        String result= HttpClientUtils.post("http://120.27.197.38:50008/message/findByHeadCode", params, null, 20000, 20000);
       
        //发短信
//        params.put("data","{\"content\":\"b新版这是一条新的短信\",\"phone\":\"15504607909\",\"tenant\":\"fytest123\","//\"supplierChannel\":\"1\",
//        		+ "\"bizType\":\"总共\",\"sendType\":\"SMS\",\"bizNo\":\"1q2w3e4r\",\"appPlatform\":\"仓配\"}");
//        String result= HttpClientUtils.post("http://192.168.3.218:8080/message/send", params, null, 10000, 10000);
//        String result= HttpClientUtils.post("http://120.27.197.38:50008/message/send", params, null, 10000, 10000);
//
        //根据短信账号查询租户列表
//        params.put("data","{\"sendType\":\"SMS\",\"loginName\":\"fyrjgstc\"}");
//        String result= HttpClientUtils.post("http://192.168.3.218:8080/tenant/queryTenantByLoginName", params, null, 10000, 10000);
        
        
        
        //增和修改租户信息
//        Tenant t = new Tenant();
//        t.setCode("hailongTest");
//        t.setName("海龙测试3");
//        t.setUseStatus("Y");
//        t.setHeadCode("wuliu123");
//        t.setDefaultSmsSupplierNo("1");
//        t.setDefaultVoiceSupplierNo("1");
//        t.setRemark("备注");
//        params.put("data",JSON.toJSONString(t));
//        String result= HttpClientUtils.post("http://192.168.3.218:8080/tenant/saveOrUpdateTenant", params, null, 10000, 10000);
        
        
//        //增和修改供应商信息
//        SmsSupplier t = new SmsSupplier();
//        t.setTenantCode("hailongTest");
//        t.setSupplierNo("2");
//        t.setViewSort(2);
//        t.setAppPlatform("金融平台");
//        t.setIsUsed("Y");
//        params.put("data",JSON.toJSONString(t));
//        String result= HttpClientUtils.post("http://192.168.3.218:8080/tenant/saveOrUpdateSupplier", params, null, 10000, 10000);
        
        
        //增和修改供应商属性信息
//        SmsSupplierProperty t = new SmsSupplierProperty();
//        t.setTenantCode("hailongTest");
//        t.setSupplierNo("2");
//        t.setPropertyName("login");
//        t.setPropertyValue("ppp");
//        t.setIsUsed("Y");
//        t.setRemark("remark");
//        SmsSupplierProperty t2 = new SmsSupplierProperty();
//        t2.setTenantCode("hailongTest");
//        t2.setSupplierNo("2");
//        t2.setPropertyName("login3");
//        t2.setPropertyValue("ppp222222");
//        t2.setIsUsed("N");
//        t2.setRemark("remark22222");
//        List list = new ArrayList();
//        list.add(t);
//        list.add(t2);

//        params.put("data",JSON.toJSONString(list));
//        String result= HttpClientUtils.post("http://192.168.3.218:8080/tenant/saveOrUpdateSupplierProperty", params, null, 10000, 10000);

        /******************************
         * 微网通联通道
         ******************************/
        //查询发送纪录
//        params.put("tenant", "fytest123");
//        params.put("begin", "20171023000000");
//        params.put("end", "20171024151515");
//        params.put("data", "{\"page\":\"1\",\"size\":\"20\",\"mobilePhone\":\"17703601308\"}");
//        //发送手机号mobilePhone
//        //发送内容msgcontent
//        //每页多少条pageSize
//        //当前页curPage
//        //开始时间startTime   格式为yyyyMMddHHmmss
//        //结束时间endTime
//        String strUrl = "http://192.168.3.222:8100/smscenter-restful-api/message/find/";
//        String result= HttpClientUtils.post(strUrl, params, null, 10000, 10000);

        //发短信(文字)
//        params.put("data","{\"content\":\"新版这是一条新的短信测试\",\"phone\":\"17703601308\",\"tenant\":\"fytest123\","//\"supplierChannel\":\"1\",
//        		+ "\"bizType\":\"总共\",\"sendType\":\"SMS\",\"bizNo\":\"1q2w3e4r\",\"appPlatform\":\"仓配\"}");
//        String result= HttpClientUtils.post("http://192.168.3.222:8100/smscenter-restful-api/message/send", params, null, 10000, 10000);

        //发短信(语音)
//        params.put("data","{\"content\":\"新版这是一条新的语音短信测试\",\"phone\":\"17703601308\",\"tenant\":\"fytest123\","//\"supplierChannel\":\"1\",
//        		+ "\"bizType\":\"总共\",\"sendType\":\"VOICE\",\"bizNo\":\"1q2w3e4r\",\"appPlatform\":\"仓配\"}");
//        String result= HttpClientUtils.post("http://192.168.3.222:8100/smscenter-restful-api/message/send", params, null, 10000, 10000);


        //查询余额
//        params.put("tenant", "fytest123");
//        params.put("data", "{}");  //\"appPlatform\":\"仓配\"
//        String result= HttpClientUtils.post("http://192.168.3.222:8100/smscenter-restful-api/smsqueryV2/queryBalanceV2", params, null, 20000, 20000);

        //交易中心[消费]
//        params.put("userName", "lwhtest");
//        params.put("password", "123456");
//        params.put("type", "短信");
//        params.put("money", "5.5");
//        params.put("companyCode", "Fy56");
//        params.put("remark", "CESHI消费");
//        String result= HttpClientUtils.post("http://localhost:8088/tradingcenter-restful/consumeManager/consume", params, null, 200000, 200000);

        //交易中心[账目系统自动回冲(交易失败时,做账目的回冲.就是说提前预扣的费用,再以系统自动充值的名义补充回去.)]
//        params.put("userName", "lwhtest");
//        params.put("password", "123456");
//        params.put("tradNo", "Fy5620171024130952339");
//        params.put("companyCode", "Fy56");
//        params.put("remark", "");
//        String result= HttpClientUtils.post("http://localhost:8091/test/consumeManager/consumeRevert", params, null, 200000, 200000);

//        System.out.println(result);
//
        //测试短信回冲接口
        for(int i=0;i<2;i++){
            params.put("userName", "root");
            params.put("password", "root");
            params.put("tradNo", "Fy5620171025102231815");
            params.put("companyCode", "Fy56");
            params.put("remark", "");
            String result= HttpClientUtils.post("http://localhost:8091/test/consumeManager/consumeRevert", params, null, 200000, 200000);
            System.out.println("回冲:"+i+result);
        }
        //测试短信消费接口
//        for(int i=0;i<5000;i++){
//            params.put("userName", "root");
//            params.put("password", "root");
//            params.put("type", "短信");
//            params.put("money", "0.3");
//            params.put("companyCode", "Fy56");
//            params.put("remark", "消费CESHI2");
//            String result= HttpClientUtils.post("http://localhost:8091/test/consumeManager/consume", params, null, 200000, 200000);
//            System.out.println("消费测试"+i+result);
//        }

    }

}
